<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>title</title>
</head>

<body>
    <h1 id="demo">颜色</h1>
    <p>单击按钮可为H1元素添加颜色:</p>
    <button onclick="myFunc01()">红</button>
    <button onclick="myFunc02()">橙</button>
    <button onclick="myFunc03()">黄</button>
    <button onclick="myFunc04()">绿</button>
    <button onclick="myFunc05()">蓝</button>
    <button onclick="myFunc06()">紫</button>
    <script>
        function myFunc01() {
            document.getElementById("demo").style.color = "red";
        }

        function myFunc02() {
            document.getElementById("demo").style.color = "orange";
        }

        function myFunc03() {
            document.getElementById("demo").style.color = "yellow";
        }

        function myFunc04() {
            document.getElementById("demo").style.color = "green";
        }

        function myFunc05() {
            document.getElementById("demo").style.color = "blue";
        }

        function myFunc06() {
            document.getElementById("demo").style.color = "purple";
        }
    </script>
</body>

</html>